/**
 **************************************************************************************************************************
 * 
 **************************************************************************************************************************
 * @file RBEffectPass.h
 **************************************************************************************************************************/

#pragma once

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBEffectPass.h)
#endif


/**************************************************************************************************************************
 * Includes
 **************************************************************************************************************************/
#include "RBMain/RBCommon.h"
#include "RBRenderProcess/RBShader.h"

/**************************************************************************************************************************
 * Forward declarations
 **************************************************************************************************************************/
struct RBShader;
struct RBShaderVariable;
class RBRenderer;
class RBShaderResourceView;

/**************************************************************************************************************************
 * Classes
 **************************************************************************************************************************/

class RBEffectPass
{
    friend class RBEffectCompiler;
public:

                            RBEffectPass        ();
                           ~RBEffectPass        ();

    const RBShader*         GetComputeShader    () const { return m_aShaders[EST_CS]; }
    const RBShader*         GetVertexShader     () const { return m_aShaders[EST_VS]; }
    const RBShader*         GetPixelShader      () const { return m_aShaders[EST_PS]; }

    const RBShader*         GetShader           (EShaderType eType) const { return m_aShaders[eType]; }
    RBShader*               GetShader           (EShaderType eType) { return m_aShaders[eType]; }
    void                    SetShader           (EShaderType eType, RBShader* pShader) { m_aShaders[eType] = pShader; }

    RBShaderVariable*       GetVariableByName   (const RBString& strName) const;

    // These functions MUST BE stateless: it is mandatory in order to insure thread safety
    void                    Begin               (RBRenderer* pRenderer, const void* pRawData, const RBShaderResourceView** ppViews, const RBShaderSamplerState** ppSamplers ) const;
    void                    End                 (RBRenderer* pRenderer) const;

    void                    CreateIASignature   (const void* pIASig, uint32 uiSigSize);

    const void*             GetIASignature      () const { return m_pIASignature; }
    uint32                  GetIASignatureSize  () const { return m_uiIASignatureSize; }

private:
    RBShader*               m_aShaders[EST_COUNT];
    void*                   m_pIASignature;
    uint32                  m_uiIASignatureSize;
};